package short_semester.questionnaire_planet.dao;

import org.omg.CORBA.INTERNAL;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import short_semester.questionnaire_planet.pojo.Questionnaire;
import short_semester.questionnaire_planet.pojo.Relation;

import javax.transaction.Transactional;
import java.util.List;

public interface RelationDao extends JpaRepository<Relation,Integer> {

    List<Relation> findByQuestionnaire(Questionnaire questionnaire);

    List<Relation> findByQuestionIdAndType(Integer questionId,String type);
<<<<<<< HEAD
    
    Boolean existsByQuestionnaire(Questionnaire questionnaire);
    
=======

    Boolean existsByQuestionnaire(Questionnaire questionnaire);

>>>>>>> refs/remotes/origin/dev
    List<Relation> findByRelationIdAndRelationType(Integer relationId,String relationType);

    @Transactional
    @Modifying
    List<Relation> findByQuestionIdAndTypeAndRelationIdAndRelationType(Integer questionId, String type, Integer relationId,String relationType);

    @Transactional
    @Modifying
    void deleteByRelationIdAndRelationType(Integer relationId,String type);
<<<<<<< HEAD
    
    @Transactional
    @Modifying
    void deleteByOptionIdAndRelationType(Integer optionId,String type);
    
=======

    @Transactional
    @Modifying
    void deleteByOptionIdAndRelationType(Integer optionId,String type);

>>>>>>> refs/remotes/origin/dev
    @Transactional
    @Modifying
    void deleteByQuestionIdAndType(Integer questionId,String type);

    @Transactional
    @Modifying
    void deleteByQuestionnaire(Questionnaire questionnaire);
}
